#include <iostream>
#include <stack>
#include <vector>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
 
void PreOrderCreate(TreeNode* &root) {
    int cur;
    cin >> cur;
    if (cur == -1) {
        root = nullptr;
    } else {
        root = new TreeNode(cur);
        PreOrderCreate(root->left);
        PreOrderCreate(root->right);
    }
}

   
vector<int> PostOrderTraversal(TreeNode* root) {
    vector<int> ans;
    if (!root)
        return ans;
    stack<TreeNode*> st;
    st.push(root);
    while (!st.empty()) {
        TreeNode* cur = st.top();
        st.pop();
        if (cur) {
            st.push(cur);
            st.push(nullptr);
            if (cur->right)
                st.push(cur->right);
            if (cur->left)
                st.push(cur->left);
        } else {
            
            ans.push_back(st.top()->val);
            st.pop();
        }
    }
    return ans;
}
int main(void)
{
    TreeNode* t;
    PreOrderCreate(t);
    vector<int> ans = PostOrderTraversal(t);
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i];
    }

    return 0;
}